package org.rugby.online.impl;

import java.util.Random;

import org.rugby.online.core.skills.RboSkill;
import org.rugby.online.core.skills.RboSkillType;

public class DefaultSkill implements RboSkill {

	/**
	 * Serial number
	 */
	private static final long serialVersionUID = 8308073227522383034L;
	
	public static final int MIN_VALUE = 0;
	public static final int MAX_INIT_VALUE = 20;
	public static final int MAX_VALUE = 100;
	
	private RboSkillType type;
	private int level;
	
	public DefaultSkill(RboSkillType type) {
		super();
		this.type = type;
		this.level = (new Random()).nextInt(MAX_INIT_VALUE - MIN_VALUE) + MIN_VALUE;
	}
	
	@Override
	public RboSkillType getType() {
		return this.type;
	}

	@Override
	public int getLevel() {
		return this.level;
	}

	@Override
	public void popUp() {
		if (this.level < MAX_VALUE) {
			this.level++;
		}
	}

	@Override
	public void popUpBy(int value) {
		for (int i = 0; i < value; i++) {
			this.popUp();
		}
	}

	@Override
	public void popDown() {
		if (this.level > MIN_VALUE) {
			this.level--;
		}
	}

	@Override
	public void popDownBy(int value) {
		for (int i = 0; i < value; i++) {
			this.popDown();
		}
	}

}
